package com.itmk.web.room.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.itmk.utils.ResultUtils;
import com.itmk.utils.ResultVo;
import com.itmk.web.room.entity.Room;
import com.itmk.web.room.entity.RoomPage;
import com.itmk.web.room.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author java实战基地
 * @since 2023-10-11
 */
@RestController
@RequestMapping("/api/room")
public class RoomController {
    @Autowired
    private RoomService roomService;

    //新增
    @PostMapping
    public ResultVo add(@RequestBody Room room){
        roomService.add(room);
        return ResultUtils.success("新增成功");
    }

    //编辑
    @PutMapping
    public ResultVo edit(@RequestBody Room room){
        roomService.edit(room);
        return ResultUtils.success("编辑成功");
    }

    //删除
    @DeleteMapping("/{roomId}")
    public ResultVo delete(@PathVariable("roomId") Integer roomId){
        roomService.delete(roomId);
        return ResultUtils.success("删除成功");
    }

    //列表
    @GetMapping("/list")
    public ResultVo list(RoomPage parm){
        IPage<Room> list = roomService.getList(parm);
        return ResultUtils.success("查询成功",list);
    }



}

